package cate.game.play.skill.passive.hero;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.SkillActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 冬阴功在场时，所有己方角色根据暴击产生的伤害的15%，为全体己方单位回血，恢复量不超过冬阴功最大生命值的25%
 */
public class 附香PH extends PassiveHandler {

	private double 恢复系数;

	private double 最大系数;

	//恢复系数=1500&最大系数=2500
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		恢复系数 = args.getWDouble("恢复系数", 0d);
		最大系数 = args.getWDouble("最大系数", 0d);
	}

	public void addHealCoeff(double coeff) {
		this.恢复系数 += coeff;
	}

	@Override
	public void afterOtherOneAttack(SkillActionCtx action, Fighter target, long totalDamage, boolean strike) {
		if (skill.owner.isDead()) {
			return;
		}
		if (totalDamage <= 0) {
			return;
		}
		if (!strike) {
			return;
		}
		Fighter actor = action.getActor();
		if (actor.getTeam() != skill.owner.getTeam()) {
			return;
		}
		double heal = totalDamage * 恢复系数;
		heal = Math.min(heal, skill.owner.attr.total().hpTotal() * 最大系数);
		for (Fighter friend : skill.owner.getFightTeam().getFightersAlive()) {
			friend.attr.passiveHeal(action, skill.owner, heal);
		}
	}
}
